package net.lab0.tools.evo.test.stubs;

import net.lab0.tools.evo.BinaryIndividual;
import net.lab0.tools.evo.Population;
import net.lab0.tools.evo.iface.Elimination;
import net.lab0.tools.evo.iface.IndividualFactory;
import net.lab0.tools.evo.iface.Selection;

public class PopulationImplementation
extends Population<BinaryIndividual>
{
    private int maximumIteration;
    
    /**
     * @see Population
     * @param maximumIteration
     *            The maximum number of iterations to do. Must be positive.
     * @throws IllegalArgumentException
     */
    public PopulationImplementation(int populationSize, double mutationRate, double childrenRate,
    Selection<BinaryIndividual> selection, Elimination<BinaryIndividual> elimination,
    IndividualFactory<BinaryIndividual> factory, int maximumIteration)
    throws IllegalArgumentException
    {
        super(populationSize, mutationRate, childrenRate, selection, elimination, factory);
        
        if (maximumIteration < 1)
        {
            throw new IllegalArgumentException("The number of iterations must be positive.");
        }
        
        this.maximumIteration = maximumIteration;
    }
    
    @Override
    public boolean stop()
    {
        return this.iteration > maximumIteration;
    }
    
}
